package cn.dakaqi.dao;

import cn.dakaqi.entities.ActivitySignRecord;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.query.Param;

/**
 * Created by chunyang on 2016/4/17.
 */
public interface ActivitySignRecordDao extends PagingAndSortingRepository<ActivitySignRecord, Long>, JpaSpecificationExecutor<ActivitySignRecord>
{
//    @Query(nativeQuery = true,value = "select CREATE_TIME from U_ACTIVITY_SING_RECORD where VOLUNTEER_ID =:volunteerId and ACTIVITY_ID =:activityId order by CREATE_TIME asc ")
//    ActivitySignRecord findFirstRecord(@Param("volunteerId") Long volunteerId,@Param("activityId") Long activityId);
//    @Query(nativeQuery = true,value = "select CREATE_TIME from U_ACTIVITY_SING_RECORD where VOLUNTEER_ID =:volunteerId and ACTIVITY_ID =:activityId order by CREATE_TIME DESC ")
//    ActivitySignRecord findLastRecord(@Param("volunteerId") Long volunteerId,@Param("activityId") Long activityId);
    @Query(nativeQuery = true,value = "select CREATE_TIME from U_ACTIVITY_SIGN_RECORD  where VOLUNTEER_ID =:volunteerId and ACTIVITY_ID =:activityId order by CREATE_TIME asc limit 1")
    String findFirstRecord(@Param("volunteerId") Long volunteerId, @Param("activityId") Long activityId);
    @Query(nativeQuery = true,value = "select CREATE_TIME from U_ACTIVITY_SIGN_RECORD  where VOLUNTEER_ID =:volunteerId and ACTIVITY_ID =:activityId order by CREATE_TIME DESC limit 1")
    String findLastRecord(@Param("volunteerId") Long volunteerId, @Param("activityId") Long activityId);
}
